<template>
  <div class="pandectTable">
    <el-row :gutter="20" class="seachnav">
      <el-col :xs="7" :sm="6" :md="4" :lg="6" :xl="3" class="navHeight">
        <span><img :src="returandisabled" class="returandisabled"/></span>
        <span><img :src="equiplist" class="equiplist"/></span>
        <span @click="searchShow()" v-if="this.intValue === '综合信息'" class="searchinvalid"></span>
        <span @click="dynSearchShow()" v-if="this.intValue === '动态信息'" class="searchinvalid"></span>
      </el-col>
      <el-col :xs="7" :sm="6" :md="18" :lg="18" :xl="21" class="con" >
        <p  class="seachContent">{{this.seachContent}}</p>
        <p class="seachtitle" v-show="this.intValue === '动态信息'">{{this.dynSearchTitle}}</p>
        <p class="seachtitle" v-show="this.intValue === '综合信息'">{{this.synSearchTitle}}</p>
      </el-col>
    </el-row>
    <div class="tableContent">
      <div class="contentTitle">
        <span style="font-size: 14px; font-weight: bolder">设备</span>
        <el-dropdown style="cursor: pointer" @command="handleCommand" trigger="click">
          <span class="el-dropdown-link">{{this.intValue}}
            <i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="综合信息">{{this.synthetically}}</el-dropdown-item>
            <el-dropdown-item command="动态信息">{{this.dynamic}}</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
      <div class="content">
        <dynamic-table v-show="this.intValue === '动态信息'"></dynamic-table>
        <synthetical-tbale v-show="this.intValue === '综合信息'"></synthetical-tbale>
      </div>
    </div>
    <search-dialog v-show="searchDialogShow" @giveFalse="searchDialogReturn"></search-dialog>
    <dyn-search-dialog v-show="dynSearchDialogShow" @giveFalse="dynSearchDialogReturn"></dyn-search-dialog>
  </div>
</template>
<script>
  import returandisabled from '@/assets/equipv2/returandisabled.png'
  import equiplist from '@/assets/equipv2/equiplist.png'
  import searchinvalid from '@/assets/equipv2/searchinvalid.png'
  import dynamicTable from './components/dynamicTable.vue'
  import syntheticalTbale from './components/syntheticalTable.vue'
  import searchDialog from './components/serachDialog.vue'
  import dynSearchDialog from './components/dynSearchDialog.vue'
  import Bus from './equipBus'
  export default {
    components: {
      dynamicTable,
      syntheticalTbale,
      searchDialog,
      dynSearchDialog
    },
    data() {
      return {
        returandisabled,
        equiplist,
        searchinvalid,
        intValue: '综合信息',
        synthetically: '综合信息',
        dynamic: '动态信息',
        seachContent: '设备',
        dynSearchTitle: '全部',
        synSearchTitle: '全部',
        dynSearchFromData: {},
        synSearchFromData: {},
        dynHigherSearchFromData: {},
        synHigherSearchFromData: {},
        // 弹框
        searchDialogShow: false,
        dynSearchDialogShow: false
      }
    },
    mounted() {
      // 动态接收
      Bus.$on('dynSearch', (dynSearch) => {
        console.log(dynSearch)
        this.dynSearchFromData = dynSearch
        this.dynGet()
      })
      Bus.$on('dynHigher', (dynSearchData) => {
        console.log(dynSearchData)
        this.dynHigherSearchFromData = dynSearchData
        this.dynGet()
      })
      Bus.$on('dynReset', (ResetData) => {
        console.log(ResetData)
        this.dynSearchFromData = {}
        this.dynHigherSearchFromData = {}
        this.dynSearchTitle = '全部'
      })
      // 综合接收
      Bus.$on('synSearch', (synSearch) => {
        console.log(synSearch)
        this.synSearchFromData = synSearch
        this.synGet()
      })
      Bus.$on('synHigher', (synSearchData) => {
        console.log(synSearchData)
        this.synHigherSearchFromData = synSearchData
        this.synGet()
      })
      Bus.$on('synReset', (ResetData) => {
        console.log(ResetData)
        this.synSearchFromData = {}
        this.synHigherSearchFromData = {}
        this.synSearchTitle = '全部'
      })
    },
    methods: {
      // 动态接收
      dynGet() {
        // 普通查询
        console.log(this.dynSearchFromData)
        let oTitle = ''
        let oCid = ''
        // let oStatus = ''
        let oModel = ''
        let oName = ''
        let oProduce = ''
        let oType = ''
        let oBrand = ''
        let oWork = ''
        let oOperation = ''
        let oRatedWeight = ''
        let oSpan = ''
        let oTrackLength = ''
        let oRatedPower = ''
        let oLiftingHeight = ''
        let oCatTrackMode = ''
        let oProduceDate = ''
        let oDeliveryDate = ''
        let oNextAnnual = ''
        let oInstall = ''
        let oCustomer = ''
        let oWorkshop = ''
        let oManufacturer = ''
        let oIndustrytype = ''
        if (this.dynSearchFromData.equip_cid !== '' && this.dynSearchFromData.equip_cid !== undefined) {
          oCid = '出厂编号：' + this.dynSearchFromData.equip_cid + '，'
        }
        //        if (this.synSearchFromData.equip_status !== '') {
        //          oStatus = '状态：' + localStorage.getItem('statusSelectLabel') + '，'
        //        }
        if (this.dynSearchFromData.model !== '' && this.dynSearchFromData.model !== undefined) {
          oModel = '型号：' + this.dynSearchFromData.model
        }
        if (this.dynSearchFromData.name !== '' && this.dynSearchFromData.name !== undefined) {
          oName = '设备名称：' + sessionStorage.getItem('dynNameSelectLabel') + '，'
        }
        if (this.dynSearchFromData.produce_number !== '' && this.dynSearchFromData.produce_number !== undefined) {
          oProduce = '厂内编号：' + this.dynSearchFromData.produce_number + '，'
        }
        oTitle = oCid + oProduce + oName + oModel
        // 高级查询
        console.log(this.dynHigherSearchFromData)
        if (this.dynHigherSearchFromData.equip_cid !== '' && this.dynHigherSearchFromData.equip_cid !== undefined) {
          oCid = '出厂编号：' + this.dynHigherSearchFromData.equip_cid + '，'
        }
        if (this.dynHigherSearchFromData.model !== '' && this.dynHigherSearchFromData.model !== undefined) {
          oModel = '型号：' + this.dynHigherSearchFromData.model + '，'
        }
        if (this.dynHigherSearchFromData.name !== '' && this.dynHigherSearchFromData.name !== undefined) {
          oName = '设备名称：' + sessionStorage.getItem('dynNameSelectLabel') + '，'
        }
        if (this.dynHigherSearchFromData.type !== '' && this.dynHigherSearchFromData.type !== undefined) {
          oType = '类型：' + sessionStorage.getItem('dynTypeSelectLabel') + '，'
        }
        if (this.dynHigherSearchFromData.brand !== '' && this.dynHigherSearchFromData.brand !== undefined) {
          oBrand = '设备品牌：' + sessionStorage.getItem('dynBrandSelectLabel') + '，'
        }
        if (this.dynHigherSearchFromData.work_level !== '' && this.dynHigherSearchFromData.work_level !== undefined) {
          oWork = '工作级别：' + sessionStorage.getItem('dynWorkSelectLabel') + '，'
        }
        if (this.dynHigherSearchFromData.operation_mode !== '' && this.dynHigherSearchFromData.operation_mode !== undefined) {
          oOperation = '操作方式：' + sessionStorage.getItem('dynModeSelectLabel') + '，'
        }
        if (this.dynHigherSearchFromData.rated_weight_type !== '' && this.dynHigherSearchFromData.rated_weight_type !== undefined) {
          oRatedWeight = '额定重量：' + sessionStorage.getItem('dynRatedWeightSelectLabel') + this.dynHigherSearchFromData.rated_weight + '，'
        }
        if (this.dynHigherSearchFromData.span_type !== '' && this.dynHigherSearchFromData.span_type !== undefined) {
          oSpan = '跨度：' + sessionStorage.getItem('dynSpanSelectLabel') + this.dynHigherSearchFromData.span + '，'
        }
        if (this.dynHigherSearchFromData.big_car_track_length_type !== '' && this.dynHigherSearchFromData.big_car_track_length_type !== undefined) {
          oTrackLength = '轨道长度：' + sessionStorage.getItem('dynTrackLengthSelectLabel') + this.dynHigherSearchFromData.big_car_track_length + '，'
        }
        if (this.dynHigherSearchFromData.whole_rated_power_type !== '' && this.dynHigherSearchFromData.whole_rated_power_type !== undefined) {
          oRatedPower = '额定功率：' + sessionStorage.getItem('dynRatedPowerSelectLabel') + this.dynHigherSearchFromData.whole_rated_power + '，'
        }
        if (this.dynHigherSearchFromData.lifting_height_type !== '' && this.dynHigherSearchFromData.lifting_height_type !== undefined) {
          oLiftingHeight = '起升高度：' + sessionStorage.getItem('dynLiftingHeightSelectLabel') + this.dynHigherSearchFromData.lifting_height + '，'
        }
        if (this.dynHigherSearchFromData.big_car_track_model !== '' && this.dynHigherSearchFromData.big_car_track_model !== undefined) {
          oCatTrackMode = '轨道型号：' + this.dynHigherSearchFromData.big_car_track_model + '，'
        }
        if (this.dynHigherSearchFromData.produce_date_begin !== '' && this.dynHigherSearchFromData.produce_date_begin !== undefined && this.dynHigherSearchFromData.produce_date_end !== '' && this.dynHigherSearchFromData.produce_date_end !== undefined) {
          oProduceDate = '出厂时间：' + this.dynHigherSearchFromData.produce_date_begin + '~' + this.dynHigherSearchFromData.produce_date_end + '，'
        }
        if (this.dynHigherSearchFromData.delivery_time_begin !== '' && this.dynHigherSearchFromData.delivery_time_begin !== undefined && this.dynHigherSearchFromData.delivery_time_end !== '' && this.dynHigherSearchFromData.delivery_time_end !== undefined) {
          oDeliveryDate = '服务时间：' + this.dynHigherSearchFromData.delivery_time_begin + '~' + this.dynHigherSearchFromData.delivery_time_end + '，'
        }
        if (this.dynHigherSearchFromData.next_annual_trial_begin !== '' && this.dynHigherSearchFromData.next_annual_trial_begin !== undefined && this.dynHigherSearchFromData.next_annual_trial_end !== '' && this.dynHigherSearchFromData.next_annual_trial_end !== undefined) {
          oNextAnnual = '年审时间：' + this.dynHigherSearchFromData.next_annual_trial_begin + '~' + this.dynHigherSearchFromData.next_annual_trial_end + '，'
        }
        if (this.dynHigherSearchFromData.install_position !== '' && this.dynHigherSearchFromData.install_position !== undefined) {
          oInstall = '安装位置：' + this.dynHigherSearchFromData.install_position + '，'
        }
        if (this.dynHigherSearchFromData.customer_name !== '' && this.dynHigherSearchFromData.customer_name !== undefined) {
          oCustomer = '客户名称：' + this.dynHigherSearchFromData.customer_name + '，'
        }
        if (this.dynHigherSearchFromData.workshop !== '' && this.dynHigherSearchFromData.workshop !== undefined) {
          oWorkshop = '所属车间：' + this.dynHigherSearchFromData.workshop + '，'
        }
        if (this.dynHigherSearchFromData.manufacturer !== '' && this.dynHigherSearchFromData.manufacturer !== undefined) {
          oManufacturer = '制造商：' + this.dynHigherSearchFromData.manufacturer + '，'
        }
        if (this.dynHigherSearchFromData.industry_type !== '' && this.dynHigherSearchFromData.industry_type !== undefined) {
          oIndustrytype = '行业类别：' + sessionStorage.getItem('dynIndustryTypeSelectLabel')
        }
        oTitle = oCid + oName + oModel + oType + oBrand + oWork + oOperation + oRatedWeight + oSpan + oTrackLength + oRatedPower + oLiftingHeight + oCatTrackMode + oProduceDate + oDeliveryDate + oNextAnnual + oInstall + oCustomer + oWorkshop + oManufacturer + oIndustrytype
        if (oTitle === '') {
          this.dynSearchTitle = '全部'
        } else if (oTitle !== '') {
          this.dynSearchTitle = oTitle
        }
      },
      // 综合接收
      synGet() {
        // 普通查询
        console.log(this.synSearchFromData)
        let oTitle = ''
        let oCid = ''
        // let oStatus = ''
        let oModel = ''
        let oName = ''
        let oProduce = ''
        let oType = ''
        let oBrand = ''
        let oWork = ''
        let oOperation = ''
        let oRatedWeight = ''
        let oSpan = ''
        let oTrackLength = ''
        let oRatedPower = ''
        let oLiftingHeight = ''
        let oCatTrackMode = ''
        let oProduceDate = ''
        let oDeliveryDate = ''
        let oNextAnnual = ''
        let oInstall = ''
        let oCustomer = ''
        let oWorkshop = ''
        let oManufacturer = ''
        let oIndustrytype = ''
        if (this.synSearchFromData.equip_cid !== '' && this.synSearchFromData.equip_cid !== undefined) {
          oCid = '出厂编号：' + this.synSearchFromData.equip_cid + '，'
        }
        //        if (this.synSearchFromData.equip_status !== '') {
        //          oStatus = '状态：' + localStorage.getItem('statusSelectLabel') + '，'
        //        }
        if (this.synSearchFromData.model !== '' && this.synSearchFromData.model !== undefined) {
          oModel = '型号：' + this.synSearchFromData.model
        }
        if (this.synSearchFromData.name !== '' && this.synSearchFromData.name !== undefined) {
          oName = '设备名称：' + sessionStorage.getItem('synNameSelectLabel') + '，'
        }
        if (this.synSearchFromData.produce_number !== '' && this.synSearchFromData.produce_number !== undefined) {
          oProduce = '厂内编号：' + this.synSearchFromData.produce_number + '，'
        }
        oTitle = oCid + oProduce + oName + oModel
        // 高级查询
        console.log(this.synHigherSearchFromData)
        if (this.synHigherSearchFromData.equip_cid !== '' && this.synHigherSearchFromData.equip_cid !== undefined) {
          oCid = '出厂编号：' + this.synHigherSearchFromData.equip_cid + '，'
        }
        if (this.synHigherSearchFromData.model !== '' && this.synHigherSearchFromData.model !== undefined) {
          oModel = '型号：' + this.synHigherSearchFromData.model + '，'
        }
        if (this.synHigherSearchFromData.name !== '' && this.synHigherSearchFromData.name !== undefined) {
          oName = '设备名称：' + sessionStorage.getItem('synNameSelectLabel') + '，'
        }
        if (this.synHigherSearchFromData.type !== '' && this.synHigherSearchFromData.type !== undefined) {
          oType = '类型：' + sessionStorage.getItem('synTypeSelectLabel') + '，'
        }
        if (this.synHigherSearchFromData.brand !== '' && this.synHigherSearchFromData.brand !== undefined) {
          oBrand = '设备品牌：' + sessionStorage.getItem('synBrandSelectLabel') + '，'
        }
        if (this.synHigherSearchFromData.work_level !== '' && this.synHigherSearchFromData.work_level !== undefined) {
          oWork = '工作级别：' + sessionStorage.getItem('synWorkSelectLabel') + '，'
        }
        if (this.synHigherSearchFromData.operation_mode !== '' && this.synHigherSearchFromData.operation_mode !== undefined) {
          oOperation = '操作方式：' + sessionStorage.getItem('synModeSelectLabel') + '，'
        }
        if (this.synHigherSearchFromData.rated_weight_type !== '' && this.synHigherSearchFromData.rated_weight_type !== undefined) {
          oRatedWeight = '额定重量：' + sessionStorage.getItem('synRatedWeightSelectLabel') + this.synHigherSearchFromData.rated_weight + '，'
        }
        if (this.synHigherSearchFromData.span_type !== '' && this.synHigherSearchFromData.span_type !== undefined) {
          oSpan = '跨度：' + sessionStorage.getItem('synSpanSelectLabel') + this.synHigherSearchFromData.span + '，'
        }
        if (this.synHigherSearchFromData.big_car_track_length_type !== '' && this.synHigherSearchFromData.big_car_track_length_type !== undefined) {
          oTrackLength = '轨道长度：' + sessionStorage.getItem('synTrackLengthSelectLabel') + this.synHigherSearchFromData.big_car_track_length + '，'
        }
        if (this.synHigherSearchFromData.whole_rated_power_type !== '' && this.synHigherSearchFromData.whole_rated_power_type !== undefined) {
          oRatedPower = '额定功率：' + sessionStorage.getItem('synRatedPowerSelectLabel') + this.synHigherSearchFromData.whole_rated_power + '，'
        }
        if (this.synHigherSearchFromData.lifting_height_type !== '' && this.synHigherSearchFromData.lifting_height_type !== undefined) {
          oLiftingHeight = '起升高度：' + sessionStorage.getItem('synLiftingHeightSelectLabel') + this.synHigherSearchFromData.lifting_height + '，'
        }
        if (this.synHigherSearchFromData.big_car_track_model !== '' && this.synHigherSearchFromData.big_car_track_model !== undefined) {
          oCatTrackMode = '轨道型号：' + this.synHigherSearchFromData.big_car_track_model + '，'
        }
        if (this.synHigherSearchFromData.produce_date_begin !== '' && this.synHigherSearchFromData.produce_date_begin !== undefined && this.synHigherSearchFromData.produce_date_end !== '' && this.synHigherSearchFromData.produce_date_end !== undefined) {
          oProduceDate = '出厂时间：' + this.synHigherSearchFromData.produce_date_begin + '~' + this.synHigherSearchFromData.produce_date_end + '，'
        }
        if (this.synHigherSearchFromData.delivery_time_begin !== '' && this.synHigherSearchFromData.delivery_time_begin !== undefined && this.synHigherSearchFromData.delivery_time_end !== '' && this.synHigherSearchFromData.delivery_time_end !== undefined) {
          oDeliveryDate = '服务时间：' + this.synHigherSearchFromData.delivery_time_begin + '~' + this.synHigherSearchFromData.delivery_time_end + '，'
        }
        if (this.synHigherSearchFromData.next_annual_trial_begin !== '' && this.synHigherSearchFromData.next_annual_trial_begin !== undefined && this.synHigherSearchFromData.next_annual_trial_end !== '' && this.synHigherSearchFromData.next_annual_trial_end !== undefined) {
          oNextAnnual = '年审时间：' + this.synHigherSearchFromData.next_annual_trial_begin + '~' + this.synHigherSearchFromData.next_annual_trial_end + '，'
        }
        if (this.synHigherSearchFromData.install_position !== '' && this.synHigherSearchFromData.install_position !== undefined) {
          oInstall = '安装位置：' + this.synHigherSearchFromData.install_position + '，'
        }
        if (this.synHigherSearchFromData.customer_name !== '' && this.synHigherSearchFromData.customer_name !== undefined) {
          oCustomer = '客户名称：' + this.synHigherSearchFromData.customer_name + '，'
        }
        if (this.synHigherSearchFromData.workshop !== '' && this.synHigherSearchFromData.workshop !== undefined) {
          oWorkshop = '所属车间：' + this.synHigherSearchFromData.workshop + '，'
        }
        if (this.synHigherSearchFromData.manufacturer !== '' && this.synHigherSearchFromData.manufacturer !== undefined) {
          oManufacturer = '制造商：' + this.synHigherSearchFromData.manufacturer + '，'
        }
        if (this.synHigherSearchFromData.industry_type !== '' && this.synHigherSearchFromData.industry_type !== undefined) {
          oIndustrytype = '行业类别：' + sessionStorage.getItem('synIndustryTypeSelectLabel')
        }
        oTitle = oCid + oName + oModel + oType + oBrand + oWork + oOperation + oRatedWeight + oSpan + oTrackLength + oRatedPower + oLiftingHeight + oCatTrackMode + oProduceDate + oDeliveryDate + oNextAnnual + oInstall + oCustomer + oWorkshop + oManufacturer + oIndustrytype
        if (oTitle === '') {
          this.synSearchTitle = '全部'
        } else if (oTitle !== '') {
          this.synSearchTitle = oTitle
        }
      },
      // 切换
      handleCommand(val) {
        console.log(val)
        this.intValue = val
      },
      // 综合搜索
      searchShow() {
        this.searchDialogShow = !this.searchDialogShow
        // Bus.$emit('synReturn', this.synSearchFromData)
        // Bus.$emit('synHighReturn', this.synHigherSearchFromData)
      },
      // 动态搜索
      dynSearchShow() {
        this.dynSearchDialogShow = !this.dynSearchDialogShow
      },
      // 父组件接收值
      searchDialogReturn(data) {
        this.searchDialogShow = data // data仅仅代表参数 这里等同于子组件roleDialogMask
        console.log('11')
        console.log(data)
      },
      dynSearchDialogReturn(data) {
        this.dynSearchDialogShow = data // data仅仅代表参数 这里等同于子组件roleDialogMask
        console.log('11')
        console.log(data)
      }
    }
  }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  /*************最外层**************/
  .pandectTable {
    width: 100%;
    min-height: 48vw;
    background-color: #EFEFEF;
    .seachnav {
      width: 60%;
      height: 50px;
      position: fixed;
      z-index: 2;
      top: 0;
      bottom: 0;
      line-height: 50px;
      padding-left: 20px;
      .navHeight {
        width: 120px !important;
        height: 60px;
        padding-right: 0 !important;
        .returandisabled {
          vertical-align: -webkit-baseline-middle;
        }
        .equiplist {
          vertical-align: -webkit-baseline-middle;
          margin-left: 15px;
        }
        .searchinvalid {
          display: inline-block;
          width: 20px;
          height: 20px;
          vertical-align: -webkit-baseline-middle;
          margin-left: 5px;
          background-image: url('../../assets/equipv2/searchHover.png');
          cursor: pointer;
        }
        .searchinvalid:hover {
          background-image: url('../../assets/equipv2/searchRealHover.png');
        }
      }
      .con {
        width: 600px;
        height: 60px;
        float: left;
        margin-right: 20px;
        line-height: 3px;
        padding-left: 0 !important;
        p{
          margin: 0;
          line-height: 22px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        p:nth-child(1){
          margin-top: 10px;
        }
        .seachContent {
          font-size: 18px;
          font-family: MicrosoftYaHei;
          font-weight: 400;
          padding-top: 0px;
          color: rgba(51, 51, 51, 1);
        }
        .seachtitle {
          font-size: 12px;
          font-family: MicrosoftYaHei;
          font-weight: 400;
          color: rgba(102, 102, 102, 1);
        }
      }
    }
  }
  /***************内容区域*****************/
  .tableContent{
    position: relative;
    top: 20px;
    left: 20px;
    width: 1700px;
    min-width: 1700px;
    height: 890px;
    background-color: #ffffff;
    /*border: 1px solid red;*/
    .contentTitle{
      width: inherit;
      height: 30px;
      /*border: 1px solid blue;*/
      background-color: #EFEFEF;
      .el-dropdown{
        margin-left: 30px;
        color: #000;
        .el-icon--right{
          margin-left: 0;
          font-weight: bold;
        }
      }
    }
  }
  /deep/ .v-modal{
    display: none;
  }
</style>
